package com.soho.core;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.soho.helper.PrintHelper;

public class CustomFilter implements Filter {

	@Override
	public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain)
			throws IOException, ServletException {
		 	HttpServletRequest request=(HttpServletRequest)servletRequest;
	        HttpServletResponse response=(HttpServletResponse)servletResponse;
	     
	        PrintHelper.print("【允许跨域访问】refererUrl【{}】", request.getHeader("Referer"));

	        //允许跨域访问
	        response.setHeader("Access-Control-Allow-Origin", "*"); 
	        chain.doFilter(request, response);
	}

}
